import java.util.Scanner;
import java.util.function.Predicate;

public class Task {

    // 手机号码 11 位，第一位为 1，第二位为 3-9
    public static final String REGEX_PHONE = "/* TODO */";

    // 邮箱地址格式：xxx@xxx.xxx 或 xxx@xxx.xxx.xxx
    public static final String REGEX_EMAIL = "/* TODO */";

    // 时间格式（选做）：HH:mm:ss 24小时制 00:00:00 - 23:59:59
    public static final String REGEX_TIME = "/* TODO */";

    public static void main(String[] args) {

        loopCheck("手机号码", s -> s.matches(REGEX_PHONE));
//        loopCheck("邮箱地址", s -> s.matches(REGEX_EMAIL));
//        loopCheck("时间", s -> s.matches(REGEX_TIME));
    }

    public static void loopCheck(String content, Predicate<String> predicate) {
        System.out.println("请输入" + content + "：");
        // 循环读取用户输入的字符串
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String str = scanner.nextLine();
            if (predicate.test(str)) {
                System.out.printf("您输入的%s格式正确！✔%n", content);
                break;
            } else {
                System.out.printf("您输入的%s格式错误！❌%n", content);
            }
        }
    }

}